﻿using NeXus.BIMBase;
using NeXus.BIMBase.Core;
using NeXus.BIMBase.Data;
using NeXus.p3d;
using System;
using System.Windows.Forms;
using static NeXus.p3d.GeCurveArray;

namespace checc_baseTools
{
    public class Replacement
    {
        /// <summary>
        /// 盖板涵换填
        /// </summary>
        /// <param name="replacement">换填实体</param>
        /// <param name="culvertWidth">涵洞宽度</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <param name="angle_L">左洞口角度</param>
        /// <param name="angle_R">右洞口角度</param>
        /// <returns>返回新建层底部两点</returns>
        public static BPGraphics create(ReplacementData replacement, double culvertWidth, double slope, double angle_L, double angle_R)
        {
            BPProject bPProject = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = bPProject.getActiveModel();

            culvertWidth = culvertWidth * Culvert_Help.GeneralHelpers.UOR;//净跨

            int id = replacement.Id;//层数
            int totalNumberLayers = replacement.TotalNumberLayers;//总层数

            double depth = replacement.Depth * Culvert_Help.GeneralHelpers.UOR;//换填深度
            double gap = replacement.DistanceFromLeftHole * Culvert_Help.GeneralHelpers.UOR;//换填起点距左洞口距离
            double slopeRatio = replacement.SlopeRatio;//换填坡比
            double edge = replacement.Edge * Culvert_Help.GeneralHelpers.UOR;//换填襟边
            double thickenedLength = replacement.EdgeThickeningLength * Culvert_Help.GeneralHelpers.UOR;//边部加厚长度
            double thickenedDepth = replacement.EdgeThickeningDepth * Culvert_Help.GeneralHelpers.UOR;//边部加厚深度
            string materialList = replacement.MaterialName;//换填材质集合

            //L = 深度 * 坡比
            double L = depth * slopeRatio;
            //换填最底部一半宽度(包含净跨一半) （换填深度 * 换填坡比 * 层数 -1 + 襟边 * 层数） + 净跨 /2 = 最底部一半宽度
            double bottomWidth = (L * (totalNumberLayers - 1)) + edge * totalNumberLayers + culvertWidth / 2;
            //计算裁剪下去的长度 重新加上
            double l = bottomWidth * 2 * Math.Abs(Math.Tan(angle_L * Math.PI / 180));
            double length = replacement.Length * Culvert_Help.GeneralHelpers.UOR + l;//换填长度
            //坐标原点
            GePoint3d startPoint = new GePoint3d(0, 0, 0);

            BPGraphics graphics = model.createPhysicalGraphics();
            #region 调用三遍
            //点集为空说明是第一层
            if (id == 0 && thickenedLength == 0 && thickenedDepth == 0)
            {

                //（左视图）涵洞左侧 换填点位
                //左上
                GePoint3d point3D_L1 = new GePoint3d(startPoint.x, (startPoint.y + culvertWidth / 2) + edge, startPoint.z);
                //左下
                GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y + L, point3D_L1.z - depth);

                //（左视图）涵洞右侧 换填点位
                //右上
                GePoint3d point3D_R1 = new GePoint3d(startPoint.x, (startPoint.y - culvertWidth / 2) - edge, startPoint.z);
                //右下
                GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y - L, point3D_R1.z - depth);

                //线 左下角逆时针转 左下 右下 右上 左上
                IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
                IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R2));
                IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_L2));
                IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_L1));

                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveArray.add(curve1);
                curveArray.add(curve2);
                curveArray.add(curve3);
                curveArray.add(curve4);

                //体
                GeVec3d v3d = new GeVec3d(length, 0, slope * length);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
                graphics.addSolid(solid);
                //裁剪
                graphics = crop(graphics, length, angle_L, angle_R, bottomWidth, slope);
                return graphics;
            }
            //点集不为空，并且加厚长度，加厚宽度为0，说明不是最后一层不需要加厚
            else if (id != 0 && thickenedLength == 0 && thickenedDepth == 0)
            {
                //（左视图）涵洞左侧 换填点位
                GePoint3d point3D_L1 = new GePoint3d(startPoint.x, (startPoint.y + culvertWidth / 2) + edge * id, startPoint.z - depth * id);
                point3D_L1 = new GePoint3d(point3D_L1.x, point3D_L1.y + edge, point3D_L1.z);
                GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y + L, point3D_L1.z - depth);

                //（左视图）涵洞右侧 换填点位
                GePoint3d point3D_R1 = new GePoint3d(startPoint.x, (startPoint.y - culvertWidth / 2) - edge * id, startPoint.z - depth * id);
                point3D_R1 = new GePoint3d(point3D_R1.x, point3D_R1.y - edge, point3D_R1.z);
                GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y - L, point3D_R1.z - depth);

                //线
                IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
                IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R2));
                IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_L2));
                IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_L1));

                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveArray.add(curve1);
                curveArray.add(curve2);
                curveArray.add(curve3);
                curveArray.add(curve4);

                //体
                GeVec3d v3d = new GeVec3d(length, 0, slope * length);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
                graphics.addSolid(solid);
                //裁剪
                graphics = crop(graphics, length, angle_L, angle_R, bottomWidth, slope);
                return graphics;
            }
            //点集不为空，并且加厚长度，加厚宽度不为0，说明是最后一层需要加厚
            else if (id != 0 && thickenedLength != 0 && thickenedDepth != 0)
            {
                //换填最底部一半宽度(包含净跨一半) （换填深度 * 换填坡比 * 层数 -1 + 襟边 * 层数） + 净跨 /2 = 最底部一半宽度
                bottomWidth = L * totalNumberLayers + edge * totalNumberLayers + L + culvertWidth / 2;/*(depth * replacement.SlopeRatio * (totalNumberLayers - 1)) + edge * totalNumberLayers + culvertWidth / 2;*/
                //计算裁剪下去的长度 重新加上
                l = bottomWidth * 2 * Math.Abs(Math.Tan(angle_L * Math.PI / 180));
                length = replacement.Length * Culvert_Help.GeneralHelpers.UOR + l;//换填长度
                //（左视图）涵洞左侧 换填点位
                //左上
                GePoint3d point3D_L1 = new GePoint3d(startPoint.x, (startPoint.y + culvertWidth / 2) + edge * id, startPoint.z - depth * id);
                point3D_L1 = new GePoint3d(point3D_L1.x, point3D_L1.y + edge, point3D_L1.z);
                //左下
                GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y + L, point3D_L1.z - depth);

                //（左视图）涵洞右侧 换填点位
                //右上
                GePoint3d point3D_R1 = new GePoint3d(startPoint.x, (startPoint.y - culvertWidth / 2) - edge * id, startPoint.z - depth * id);
                point3D_R1 = new GePoint3d(point3D_R1.x, point3D_R1.y - edge, point3D_R1.z);
                //右下
                GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y - L, point3D_R1.z - depth);

                //线 左下角逆时针转 左下 右下 右上 左上
                IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
                IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R2));
                IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_L2));
                IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_L1));

                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveArray.add(curve1);
                curveArray.add(curve2);
                curveArray.add(curve3);
                curveArray.add(curve4);

                //体
                //延x轴向量拉伸
                GeVec3d v3d = new GeVec3d(length, 0, slope * length);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
                graphics.addSolid(solid);

                #region 加厚部分
                //(顶视图左上加厚点 左侧加厚=LJ
                GePoint3d point3D_LJ1 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z - thickenedDepth);
                //(顶视图左下加厚点 左侧加厚=LJ
                GePoint3d point3D_LJ2 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z - thickenedDepth);
                //(顶视图右上加厚点 右侧加厚=RJ
                GePoint3d point3D_RJ1 = new GePoint3d(point3D_LJ1.x + length, point3D_LJ1.y, point3D_LJ1.z);
                //(顶视图右下加厚点 右侧加厚=RJ
                GePoint3d point3D_RJ2 = new GePoint3d(point3D_LJ2.x + length, point3D_LJ2.y, point3D_LJ2.z);
                //(左视图)线
                IGeCurveBase curve5 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_R2));
                IGeCurveBase curve6 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_LJ2));
                IGeCurveBase curve7 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ2, point3D_LJ1));
                IGeCurveBase curve8 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ1, point3D_L2));
                //(左视图)面
                GeCurveArray curveList = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList.add(curve5);
                curveList.add(curve6);
                curveList.add(curve7);
                curveList.add(curve8);
                graphics.addCurveArray(curveList);
                //(左视图)体
                GeExtrusionInfo extrusion = new GeExtrusionInfo(curveList, new GeVec3d(length, 0, slope * length), true);
                IGeSolidBase geSolid = IGeSolidBase.createGeExtrusion(extrusion);
                graphics.addSolid(geSolid);
                #endregion
                graphics = cropThicken(graphics, id, depth, thickenedDepth, thickenedLength, length, angle_L, angle_R, bottomWidth, slope);
                //材质
                //BPMaterial.setMaterialToEntity(graphics, material, true);

                return graphics;
            }
            else if (id == 0 && thickenedLength != 0 && thickenedDepth != 0)
            {
                //换填最底部一半宽度(包含净跨一半)换填深度 * 换填坡比 = L，
                //L * 层数 + 襟边 * 层数 + L（加厚） +  净跨 /2 = 最底部一半宽度
                bottomWidth = L * totalNumberLayers + edge * totalNumberLayers + L + culvertWidth / 2;
                //计算裁剪下去的长度 重新加上
                l = bottomWidth * 2 * Math.Abs(Math.Tan(angle_L * Math.PI / 180));
                length = replacement.Length * Culvert_Help.GeneralHelpers.UOR + l;//换填长度
                //（左视图）涵洞左侧 换填点位
                //左上
                GePoint3d point3D_L1 = new GePoint3d(startPoint.x, (startPoint.y + culvertWidth / 2) + edge * id, startPoint.z - depth * id);
                point3D_L1 = new GePoint3d(point3D_L1.x, point3D_L1.y + edge, point3D_L1.z);
                //左下
                GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y + L, point3D_L1.z - depth);

                //（左视图）涵洞右侧 换填点位
                //右上
                GePoint3d point3D_R1 = new GePoint3d(startPoint.x, (startPoint.y - culvertWidth / 2) - edge * id, startPoint.z - depth * id);
                point3D_R1 = new GePoint3d(point3D_R1.x, point3D_R1.y - edge, point3D_R1.z);
                //右下
                GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y - L, point3D_R1.z - depth);

                //线 左下角逆时针转 左下 右下 右上 左上
                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R2)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_L2)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_L1)));

                //体
                //延x轴向量拉伸
                GeVec3d v3d = new GeVec3d(length, 0, slope * length);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
                graphics.addSolid(solid);

                #region 加厚部分
                //(顶视图左上加厚点 左侧加厚=LJ
                GePoint3d point3D_LJ1 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z - thickenedDepth);
                //(顶视图左下加厚点 左侧加厚=LJ
                GePoint3d point3D_RJ1 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z - thickenedDepth);

                //(左视图)线
                //(左视图)面
                GeCurveArray curveList = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList.add(IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_R2)));
                curveList.add(IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_RJ1)));
                curveList.add(IGeCurveBase.createSegment(new GeSegment3d(point3D_RJ1, point3D_LJ1)));
                curveList.add(IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ1, point3D_L2)));
                graphics.addCurveArray(curveList);
                //(左视图)体
                GeExtrusionInfo extrusion = new GeExtrusionInfo(curveList, new GeVec3d(length, 0, slope * length), true);
                IGeSolidBase geSolid = IGeSolidBase.createGeExtrusion(extrusion);
                graphics.addSolid(geSolid);
                #endregion
                graphics = cropThicken(graphics, id, depth, thickenedDepth, thickenedLength, length, angle_L, angle_R, bottomWidth, slope);
                //材质
                //BPMaterial.setMaterialToEntity(graphics, material, true);

                return graphics;
            }
            else
            {
                MessageBox.Show("数据输入错误！！");
                return null;
            }
            #endregion
        }

        /// <summary>
        /// 剪切
        /// </summary>
        /// <param name="graphics">目标集</param>
        /// <param name="angle_L">左洞口角度</param>
        /// <param name="angle_R">右洞口角度</param>
        /// <param name="width">最底部宽度一半</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <returns>返回剪切后的左右视图加厚起始点</returns>
        public static BPGraphics crop(BPGraphics graphics, double length, double angle_L, double angle_R, double width, double slope)
        {
            GePoint3d ptL1 = new GePoint3d(0, width, 0);//顶视图左上
            GePoint3d ptL2 = new GePoint3d(0, -width, 0);//顶视图左下
            GePoint3d ptR1 = new GePoint3d(length, width, 0);//顶视图右上
            GePoint3d ptR2 = new GePoint3d(length, -width, 0);//顶视图右下
            if (angle_L != 0 && angle_R != 0)
            {
                //(左视图)
                //换填底部线
                IGeCurveBase geCurve_L1 = IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2));
                //换填底部宽度
                double wallLength = 0;
                geCurve_L1.getLength(ref wallLength);
                //换填角度斜边长度
                double hypotenuseLength = wallLength / Math.Cos(angle_L * Math.PI / 180);
                //换填角度短边长度
                double oppositeSide = Math.Abs(hypotenuseLength * Math.Sin(angle_L * Math.PI / 180));
                //旋转角度后的点
                GePoint3d point_L = GePoint3d.createByZero();

                if (angle_L > 0)
                {
                    //旋转角度后的点
                    point_L = Helper.Rotation(new GePoint3d(ptL2.x, ptL2.y, ptL1.z), new GePoint3d(ptL1.x, ptL1.y, ptL1.z), hypotenuseLength, -angle_L);
                }
                else
                {
                    //旋转角度后的点(左视图)
                    point_L = Helper.Rotation(new GePoint3d(ptL1.x, ptL1.y, ptL1.z), new GePoint3d(ptL2.x, ptL2.y, ptL1.z), hypotenuseLength, Math.Abs(angle_L));
                }
                //斜边和短边
                IGeCurveBase geCurve_L2 = IGeCurveBase.createSegment(new GeSegment3d(ptL2, new GePoint3d(point_L.x, point_L.y, ptL1.z + oppositeSide * slope)));
                IGeCurveBase geCurve_L3 = IGeCurveBase.createSegment(new GeSegment3d(new GePoint3d(point_L.x, point_L.y, ptL1.z + oppositeSide * slope), ptL1));
                //(左视图)面
                GeCurveArray curveList_L = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList_L.add(geCurve_L1);
                curveList_L.add(geCurve_L2);
                curveList_L.add(geCurve_L3);
                //体
                //延x轴向量拉伸
                GeVec3d v3d_L1 = new GeVec3d(0, 0, length);
                GeVec3d v3d_L2 = new GeVec3d(0, 0, -length);
                GeExtrusionInfo extrusionInfo_L1 = new GeExtrusionInfo(curveList_L, v3d_L1, true);
                GeExtrusionInfo extrusionInfo_L2 = new GeExtrusionInfo(curveList_L, v3d_L2, true);
                IGeSolidBase solid_L1 = IGeSolidBase.createGeExtrusion(extrusionInfo_L1);
                IGeSolidBase solid_L2 = IGeSolidBase.createGeExtrusion(extrusionInfo_L2);

                //(右视图)
                //换填底部线
                ptR1.set(ptR1.x, ptR1.y, 0);
                ptR2.set(ptR2.x, ptR2.y, 0);
                IGeCurveBase geCurve_R1 = IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptR2));
                //旋转角度后的点
                //旋转角度后的点
                GePoint3d point_R = GePoint3d.createByZero();
                if (angle_R > 0)
                {
                    point_R = Helper.Rotation(new GePoint3d(ptR1.x, ptR1.y, ptR1.z), new GePoint3d(ptR2.x, ptR2.y, ptR2.z), hypotenuseLength, -angle_R);
                }
                else
                {
                    point_R = Helper.Rotation(new GePoint3d(ptR2.x, ptR2.y, ptR2.z), new GePoint3d(ptR1.x, ptR1.y, ptR1.z), hypotenuseLength, Math.Abs(angle_R));
                }
                //斜边和短边
                IGeCurveBase geCurve_R2 = IGeCurveBase.createSegment(new GeSegment3d(ptR2, new GePoint3d(point_R.x, point_R.y, point_R.z)));
                IGeCurveBase geCurve_R3 = IGeCurveBase.createSegment(new GeSegment3d(new GePoint3d(point_R.x, point_R.y, point_R.z), ptR1));
                //(右视图)面
                GeCurveArray curveList_R = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList_R.add(geCurve_R1);
                curveList_R.add(geCurve_R2);
                curveList_R.add(geCurve_R3);
                //体
                //延x轴向量拉伸
                GeVec3d v3d_R1 = new GeVec3d(0, 0, -length);
                GeVec3d v3d_R2 = new GeVec3d(0, 0, length);
                GeExtrusionInfo extrusionInfo_R1 = new GeExtrusionInfo(curveList_R, v3d_R1, true);
                GeExtrusionInfo extrusionInfo_R2 = new GeExtrusionInfo(curveList_R, v3d_R2, true);
                IGeSolidBase solid_R1 = IGeSolidBase.createGeExtrusion(extrusionInfo_R1);
                IGeSolidBase solid_R2 = IGeSolidBase.createGeExtrusion(extrusionInfo_R2);
                BPGraphics graphics1 = BPApplication.getInstance().getProjectManager().getActiveModel().createPhysicalGraphics();
                graphics1.addSolid(solid_L1);
                graphics1.addSolid(solid_L2);
                graphics1.addSolid(solid_R1);
                graphics1.addSolid(solid_R2);
                //graphics1.save();
                //差集
                BPGraphics graphics2 = Element_solid.BoolDifferenceSet(graphics, graphics1, false);
                //平移到原点
                GeTransform transform = GeTransform.create(-Math.Abs(wallLength / 2 * Math.Tan(angle_R * Math.PI / 180)), 0, 0);
                BPGraphicsUtils.transformPhysicalGraphics(graphics2, transform);
                return /*graphics1*/graphics2;
            }
            else
            {
                return graphics;
            }

        }

        /// <summary>
        /// 整体式换填剪切最后一层 加厚
        /// </summary>
        /// <param name="graphics">目标集</param>
        /// <param name="angle_L">洞口角度</param>
        /// <param name="angle_R">洞口角度</param>
        /// <param name="width">最底部宽度一半</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <param name="foundationThickness">基础厚度</param>
        /// <returns>返回剪切后的左右视图加厚起始点</returns>
        public static BPGraphics cropThicken(BPGraphics graphics, double id, double depth, double edgeThickeningDepth, double edgeThickeningLength, double length, double angle_L, double angle_R, double width, double slope)
        {
            BPProject bPProject = BPApplication.getInstance().getProjectManager().getMainProject();
            BPModelBase model = bPProject.getActiveModel();

            GePoint3d ptL1 = new GePoint3d(0, width, -depth * id - depth - edgeThickeningDepth);//顶视图左上
            GePoint3d ptL2 = new GePoint3d(0, -width, ptL1.z);//顶视图左下
            GePoint3d ptR1 = new GePoint3d(length, width, ptL1.z + length * slope);//顶视图右上
            GePoint3d ptR2 = new GePoint3d(length, -width, ptL1.z + length * slope);//顶视图右下
            if (angle_L != 0 && angle_R != 0)
            {
                //(左视图)
                //换填底部线
                IGeCurveBase geCurve_L1 = IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2));
                //换填底部宽度
                double wallLength = 0;
                geCurve_L1.getLength(ref wallLength);
                //换填角度斜边长度
                double hypotenuseLength = wallLength / Math.Cos(angle_L * Math.PI / 180);
                //换填角度短边长度
                double oppositeSide = Math.Abs(hypotenuseLength * Math.Sin(angle_L * Math.PI / 180));
                GePoint3d point_L = GePoint3d.createByZero();
                if (angle_L > 0)
                    //旋转角度后的点
                    point_L = Helper.Rotation(ptL2, ptL1, hypotenuseLength, -angle_L);
                else
                    //旋转角度后的点(左视图)
                    point_L = Helper.Rotation(ptL1, ptL2, hypotenuseLength, Math.Abs(angle_L));

                //斜边和短边
                IGeCurveBase geCurve_L2 = IGeCurveBase.createSegment(new GeSegment3d(ptL2, new GePoint3d(point_L.x, point_L.y, ptL1.z - 1 + oppositeSide * slope)));
                IGeCurveBase geCurve_L3 = IGeCurveBase.createSegment(new GeSegment3d(new GePoint3d(point_L.x, point_L.y, ptL1.z - 1 + oppositeSide * slope), ptL1));
                //(左视图)面
                GeCurveArray curveList_L = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList_L.add(geCurve_L1);
                curveList_L.add(geCurve_L2);
                curveList_L.add(geCurve_L3);
                //体
                //延x轴向量拉伸
                GeVec3d v3d_L = new GeVec3d(0, 0, length);
                GeExtrusionInfo extrusionInfo_L = new GeExtrusionInfo(curveList_L, v3d_L, true);
                IGeSolidBase solid_L = IGeSolidBase.createGeExtrusion(extrusionInfo_L);

                //(右视图)
                //换填底部线
                IGeCurveBase geCurve_R1 = IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptR2));
                //旋转角度后的点
                GePoint3d point_R = GePoint3d.createByZero();
                if (angle_R > 0)
                    point_R = Helper.Rotation(ptR1, ptR2, hypotenuseLength, -angle_R);
                else
                    point_R = Helper.Rotation(ptR2, ptR1, hypotenuseLength, Math.Abs(angle_R));
                //斜边和短边
                IGeCurveBase geCurve_R2 = IGeCurveBase.createSegment(new GeSegment3d(ptR2, new GePoint3d(point_R.x, point_R.y, ptL1.z + (length - oppositeSide) * slope)));
                IGeCurveBase geCurve_R3 = IGeCurveBase.createSegment(new GeSegment3d(new GePoint3d(point_R.x, point_R.y, ptL1.z + (length - oppositeSide) * slope), ptR1));
                //(右视图)面
                GeCurveArray curveList_R = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList_R.add(geCurve_R1);
                curveList_R.add(geCurve_R2);
                curveList_R.add(geCurve_R3);
                //体
                //延x轴向量拉伸
                GeVec3d v3d_R = new GeVec3d(0, 0, length);
                GeExtrusionInfo extrusionInfo_R = new GeExtrusionInfo(curveList_R, v3d_R, true);
                IGeSolidBase solid_R = IGeSolidBase.createGeExtrusion(extrusionInfo_R);

                //前视图 加厚
                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                if (angle_L > 0 && angle_R > 0)
                {
                    //点 左上角开始逆时针转 左上 左下 右下 右上
                    //Z值 为起点到该点的长度×坡度
                    ptL1 = new GePoint3d(point_L.x + edgeThickeningLength, point_L.y, ptL1.z + (oppositeSide + edgeThickeningLength) * slope);
                    ptL2 = new GePoint3d(ptL2.x + edgeThickeningLength, ptL2.y, ptL2.z + edgeThickeningLength * slope);
                    ptR2 = new GePoint3d(point_R.x - edgeThickeningLength, point_R.y, ptL2.z + (length - oppositeSide - edgeThickeningLength) * slope);
                    ptR1 = new GePoint3d(ptR1.x - edgeThickeningLength, ptR1.y, ptL1.z + (length - edgeThickeningLength) * slope);


                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL2, ptR2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR2, ptR1)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptL1)));
                }
                else if (angle_L < 0 && angle_R < 0)
                {
                    //点 左上角开始逆时针转 左上 左下 右下 右上
                    //Z值 为起点到该点的长度×坡度
                    ptL1 = new GePoint3d(ptL1.x + edgeThickeningLength, ptL1.y, ptL1.z + edgeThickeningLength * slope);
                    ptL2 = new GePoint3d(point_L.x + edgeThickeningLength, point_L.y, ptL2.z + (oppositeSide + edgeThickeningLength) * slope);
                    ptR2 = new GePoint3d(ptR2.x - edgeThickeningLength, ptR2.y, ptL2.z + (length - edgeThickeningLength) * slope);
                    ptR1 = new GePoint3d(point_R.x - edgeThickeningLength, point_R.y, ptL1.z + (length - oppositeSide - edgeThickeningLength) * slope);

                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL2, ptR2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR2, ptR1)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptL1)));
                }
                else if (angle_L > 0 && angle_R < 0)
                {
                    //点 左上角开始逆时针转 左上 左下 右下 右上
                    //Z值 为起点到该点的长度×坡度
                    ptL1 = new GePoint3d(point_L.x + edgeThickeningLength, point_L.y, ptL1.z + (oppositeSide + edgeThickeningLength) * slope);
                    ptL2 = new GePoint3d(ptL2.x + edgeThickeningLength, ptL2.y, ptL2.z + edgeThickeningLength * slope);
                    ptR2 = new GePoint3d(ptR2.x - edgeThickeningLength, ptR2.y, ptL2.z + (length - edgeThickeningLength) * slope);
                    ptR1 = new GePoint3d(point_R.x - edgeThickeningLength, point_R.y, ptL1.z + (length - oppositeSide - edgeThickeningLength) * slope);

                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL2, ptR2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR2, ptR1)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptL1)));
                }
                else if (angle_L < 0 && angle_R > 0)
                {
                    //点 左上角开始逆时针转 左上 左下 右下 右上
                    //Z值 为起点到该点的长度×坡度
                    ptL1 = new GePoint3d(ptL1.x + edgeThickeningLength, ptL1.y, ptL1.z + edgeThickeningLength * slope);
                    ptL2 = new GePoint3d(point_L.x + edgeThickeningLength, point_L.y, ptL2.z + (oppositeSide + edgeThickeningLength) * slope);
                    ptR2 = new GePoint3d(point_R.x - edgeThickeningLength, point_R.y, ptL2.z + (length - oppositeSide - edgeThickeningLength) * slope);
                    ptR1 = new GePoint3d(ptR1.x - edgeThickeningLength, ptR1.y, ptL1.z + (length - edgeThickeningLength) * slope);

                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL2, ptR2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR2, ptR1)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptL1)));
                }
                //graphics.addCurveVector(curveArray);
                //graphics.save();
                //体
                //延x轴向量拉伸
                GeVec3d v3d1 = new GeVec3d(0, 0, depth);
                GeVec3d v3d2 = new GeVec3d(0, 0, -depth);
                GeExtrusionInfo extrusionInfo1 = new GeExtrusionInfo(curveArray, v3d1, true);
                GeExtrusionInfo extrusionInfo2 = new GeExtrusionInfo(curveArray, v3d2, true);
                IGeSolidBase solid1 = IGeSolidBase.createGeExtrusion(extrusionInfo1);
                IGeSolidBase solid2 = IGeSolidBase.createGeExtrusion(extrusionInfo2);

                BPGraphics graphics1 = model.createPhysicalGraphics();
                graphics1.addSolid(solid1);
                graphics1.addSolid(solid2);
                graphics1.addSolid(solid_L);
                graphics1.addSolid(solid_R);
                //graphics1.save();
                //差集
                BPGraphics graphics2 = Element_solid.BoolDifferenceSet(graphics, graphics1, false);
                //平移到原点
                GeTransform transform = GeTransform.create(-Math.Abs(wallLength / 2 * Math.Tan(angle_R * Math.PI / 180)), 0, 0);
                BPGraphicsUtils.transformPhysicalGraphics(graphics2, transform);

                return /*graphics1*/graphics2;
            }
            else
            {
                //前视图 加厚
                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                //点 左上角开始逆时针转
                //Z值 为起点到该点的长度×坡度
                GePoint3d point1 = new GePoint3d(ptL1.x + edgeThickeningLength, ptL1.y, ptL1.z + edgeThickeningLength * slope);
                GePoint3d point2 = new GePoint3d(ptL2.x + edgeThickeningLength, ptL2.y, ptL2.z + edgeThickeningLength * slope);
                GePoint3d point3 = new GePoint3d(ptR2.x - edgeThickeningLength, ptR2.y, ptL2.z + (length - edgeThickeningLength) * slope);
                GePoint3d point4 = new GePoint3d(ptR1.x - edgeThickeningLength, ptR1.y, ptL1.z + (length - edgeThickeningLength) * slope);

                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point1, point2)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point2, point3)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point3, point4)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point4, point1)));

                //体
                //延x轴向量拉伸
                GeVec3d v3d = new GeVec3d(0, 0, edgeThickeningDepth /*+ 1*/);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);

                BPGraphics graphics1 = model.createPhysicalGraphics();
                graphics1.addSolid(solid);
                //graphics1.save();
                //差集
                BPGraphics graphics2 = Element_solid.BoolDifferenceSet(graphics, graphics1, false);
                return graphics2;
            }
        }






        /// <summary>
        /// 分离式换填
        /// </summary>
        /// <param name="replacement">换填实体</param>
        /// <param name="culvertWidth">涵洞宽度</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <param name="angle_L">左洞口角度</param>
        /// <param name="angle_R">右洞口角度</param>
        /// <param name="insideLengthFoundation">基础内侧长度</param>
        /// <param name="foundationWidth">基础宽度</param>
        /// <param name="foundationThickness">基础厚度</param>
        /// <returns>返回新建层底部两点</returns>
        public static BPGraphics create(ReplacementData replacement, double culvertWidth, double slope, double angle_L, double angle_R, double insideLengthFoundation, double foundationWidth, double foundationThickness)
        {
            culvertWidth = culvertWidth * Culvert_Help.GeneralHelpers.UOR;//净跨

            insideLengthFoundation = insideLengthFoundation * Culvert_Help.GeneralHelpers.UOR;//基础内侧长度

            foundationWidth = foundationWidth * Culvert_Help.GeneralHelpers.UOR;//基础宽度

            foundationThickness = foundationThickness * Culvert_Help.GeneralHelpers.UOR;//基础厚度

            int id = replacement.Id;//层数
            int totalNumberLayers = replacement.TotalNumberLayers;//总层数

            double depth = replacement.Depth * Culvert_Help.GeneralHelpers.UOR;//换填深度
            double edge = replacement.Edge * Culvert_Help.GeneralHelpers.UOR;//换填襟边
            double gap = replacement.DistanceFromLeftHole * Culvert_Help.GeneralHelpers.UOR;//换填起点距左洞口距离
            double slopeRatio = replacement.SlopeRatio;//换填坡比
            double thickenedLength = replacement.EdgeThickeningLength * Culvert_Help.GeneralHelpers.UOR;//边部加厚长度
            double thickenedDepth = replacement.EdgeThickeningDepth * Culvert_Help.GeneralHelpers.UOR;//边部加厚深度

            //换填最底部一半宽度(包含净跨一半) （换填深度 * 换填坡比 * 层数 -1) + (襟边 * 层数） + 净跨 /2 + (基础宽度 - 内侧宽度) = 最底部一半宽度
            double bottomWidth = ((depth * replacement.SlopeRatio * totalNumberLayers) + (edge * totalNumberLayers) + (culvertWidth / 2) + foundationWidth);

            //计算裁剪下去的长度 重新加上
            double l = bottomWidth * 2 * Math.Abs(Math.Tan(angle_L * Math.PI / 180));

            double length = replacement.Length * Culvert_Help.GeneralHelpers.UOR + l;//换填长度

            string materialList = replacement.MaterialName;//换填材质集合
            //坐标原点
            GePoint3d startPoint = new GePoint3d(0, 0, 0);
            //L = 深度 * 坡比
            double L = depth * slopeRatio;

            BPGraphics graphics = BPApplication.getInstance().getProjectManager().getActiveModel().createPhysicalGraphics();
            #region 调用三遍
            //点集为空说明是第一层
            if (id == 0 && thickenedLength == 0 && thickenedDepth == 0)
            {
                //（左视图）涵洞左侧 换填点位
                //内侧左上
                GePoint3d ptInnerTop_L = new GePoint3d(startPoint.x, culvertWidth / 2 - insideLengthFoundation, startPoint.z);
                //内侧左下
                GePoint3d ptInnerBot_L = new GePoint3d(ptInnerTop_L.x, ptInnerTop_L.y, ptInnerTop_L.z - foundationThickness);
                //外侧左上
                GePoint3d ptOuterTop_L = new GePoint3d(ptInnerBot_L.x, ptInnerBot_L.y + foundationWidth + edge, ptInnerBot_L.z);
                //外侧左下
                GePoint3d ptOuterBot_L = new GePoint3d(ptOuterTop_L.x, ptOuterTop_L.y + L, ptOuterTop_L.z - depth);

                //（左视图）涵洞右侧 换填点位
                //内侧右上
                GePoint3d ptInnerTop_R = new GePoint3d(startPoint.x, -culvertWidth / 2 + insideLengthFoundation, startPoint.z);
                //内侧右下
                GePoint3d ptInnerBot_R = new GePoint3d(ptInnerTop_R.x, ptInnerTop_R.y, ptInnerTop_R.z - foundationThickness);
                //外侧右上
                GePoint3d ptOuterTop_R = new GePoint3d(ptInnerBot_R.x, ptInnerBot_R.y - foundationWidth - edge, ptInnerBot_R.z);
                //内侧右下
                GePoint3d ptOuterBot_R = new GePoint3d(ptOuterTop_R.x, ptOuterTop_R.y - L, ptOuterTop_R.z - depth);

                //线 左下角逆时针转 左下 右下 右上 左上
                GePoint3dCollection point3Ds = new GePoint3dCollection
                {
                    ptInnerTop_L,ptInnerBot_L,ptOuterTop_L,ptOuterBot_L,ptOuterBot_R,ptOuterTop_R,ptInnerBot_R,ptInnerTop_R
                };
                //面
                GeCurveArray curveArray = GeCurveArray.createLinestringArray(point3Ds, BoundaryType.BOUNDARY_TYPE_Outer, true);

                //体
                GeVec3d v3d = new GeVec3d(length, 0, Math.Tan(Math.PI / 180 * 90 * slope) * length);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
                graphics.addSolid(solid);
                //裁剪
                graphics = crop(graphics, length, angle_L, angle_R, bottomWidth, slope);
                //graphics.save();
                return graphics;
            }
            //点集不为空，并且加厚长度，加厚宽度为0，说明不是最后一层不需要加厚
            else if (id != 0 && thickenedLength == 0 && thickenedDepth == 0)
            {
                //（左视图）涵洞左侧 换填点位
                GePoint3d point3D_L1 = new GePoint3d(startPoint.x, startPoint.y + culvertWidth / 2 + edge * id + foundationWidth - insideLengthFoundation, startPoint.z - depth * id - foundationThickness);
                point3D_L1 = new GePoint3d(point3D_L1.x, point3D_L1.y + edge, point3D_L1.z);
                GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y + L, point3D_L1.z - depth);

                //（左视图）涵洞右侧 换填点位
                GePoint3d point3D_R1 = new GePoint3d(startPoint.x, startPoint.y - culvertWidth / 2 - edge * id - foundationWidth + insideLengthFoundation, startPoint.z - depth * id - foundationThickness);
                point3D_R1 = new GePoint3d(point3D_R1.x, point3D_R1.y - edge, point3D_R1.z);
                GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y - L, point3D_R1.z - depth);

                //线
                IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
                IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R2));
                IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_L2));
                IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_L1));

                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveArray.add(curve1);
                curveArray.add(curve2);
                curveArray.add(curve3);
                curveArray.add(curve4);

                //体
                GeVec3d v3d = new GeVec3d(length, 0, Math.Tan(Math.PI / 180 * 90 * slope) * length);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
                graphics.addSolid(solid);
                //裁剪
                graphics = crop(graphics, length, angle_L, angle_R, bottomWidth, slope);
                return graphics;
            }
            //id为第一层，并且加厚长度，加厚宽度不为0，说明是第一层也是最后一层需要加厚
            else if (id == 0 && thickenedLength != 0 && thickenedDepth != 0)
            {
                //（左视图）涵洞左侧 换填点位
                //内侧左上
                GePoint3d ptInnerTop_L = new GePoint3d(startPoint.x, culvertWidth / 2 - insideLengthFoundation, startPoint.z);
                //内侧左下
                GePoint3d ptInnerBot_L = new GePoint3d(ptInnerTop_L.x, ptInnerTop_L.y, ptInnerTop_L.z - foundationThickness);
                //外侧左上
                GePoint3d ptOuterTop_L = new GePoint3d(ptInnerBot_L.x, ptInnerBot_L.y + foundationWidth + edge, ptInnerBot_L.z);
                //外侧左下
                GePoint3d ptOuterBot_L = new GePoint3d(ptOuterTop_L.x, ptOuterTop_L.y + L, ptOuterTop_L.z - depth);

                //（左视图）涵洞右侧 换填点位
                //内侧右上
                GePoint3d ptInnerTop_R = new GePoint3d(startPoint.x, -culvertWidth / 2 + insideLengthFoundation, startPoint.z);
                //内侧右下
                GePoint3d ptInnerBot_R = new GePoint3d(ptInnerTop_R.x, ptInnerTop_R.y, ptInnerTop_R.z - foundationThickness);
                //外侧右上
                GePoint3d ptOuterTop_R = new GePoint3d(ptInnerBot_R.x, ptInnerBot_R.y - foundationWidth - edge, ptInnerBot_R.z);
                //内侧右下
                GePoint3d ptOuterBot_R = new GePoint3d(ptOuterTop_R.x, ptOuterTop_R.y - L, ptOuterTop_R.z - depth);

                //线 左下角逆时针转 左下 右下 右上 左上
                GePoint3dCollection point3Ds = new GePoint3dCollection
                {
                    ptInnerTop_L,ptInnerBot_L,ptOuterTop_L,ptOuterBot_L,ptOuterBot_R,ptOuterTop_R,ptInnerBot_R,ptInnerTop_R
                };
                //面
                GeCurveArray curveArray = GeCurveArray.createLinestringArray(point3Ds, BoundaryType.BOUNDARY_TYPE_Outer, true);

                //体
                GeVec3d v3d = new GeVec3d(length, 0, Math.Tan(Math.PI / 180 * 90 * slope) * length);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
                graphics.addSolid(solid);

                #region 加厚部分
                //(顶视图左上加厚点 左侧加厚=LJ
                GePoint3d point3D_LJ1 = new GePoint3d(ptOuterBot_L.x, ptOuterBot_L.y + L, ptOuterBot_L.z - thickenedDepth);
                //(顶视图左下加厚点 左侧加厚=LJ
                GePoint3d point3D_LJ2 = new GePoint3d(ptOuterBot_R.x, ptOuterBot_R.y - L, ptOuterBot_R.z - thickenedDepth);
                //(左视图)线
                IGeCurveBase curve5 = IGeCurveBase.createSegment(new GeSegment3d(ptOuterBot_L, ptOuterBot_R));
                IGeCurveBase curve6 = IGeCurveBase.createSegment(new GeSegment3d(ptOuterBot_R, point3D_LJ2));
                IGeCurveBase curve7 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ2, point3D_LJ1));
                IGeCurveBase curve8 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ1, ptOuterBot_L));
                //(左视图)面
                GeCurveArray curveList = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList.add(curve5);
                curveList.add(curve6);
                curveList.add(curve7);
                curveList.add(curve8);
                graphics.addCurveArray(curveList);
                //(左视图)体
                GeExtrusionInfo extrusion = new GeExtrusionInfo(curveList, new GeVec3d(length, 0, Math.Tan(Math.PI / 180 * 90 * slope) * length), true);
                IGeSolidBase geSolid = IGeSolidBase.createGeExtrusion(extrusion);
                graphics.addSolid(geSolid);
                #endregion
                graphics = cropThicken(graphics, id, depth, thickenedDepth, thickenedLength, length, angle_L, angle_R, bottomWidth, slope, foundationThickness);

                return graphics;
            }
            //点集不为空，并且加厚长度，加厚宽度不为0，说明是最后一层需要加厚
            else if (thickenedLength != 0 && thickenedDepth != 0)
            {
                //（左视图）涵洞左侧 换填点位
                //左上
                GePoint3d point3D_L1 = new GePoint3d(startPoint.x, (startPoint.y + culvertWidth / 2) + edge * id + foundationWidth, startPoint.z - depth * id - foundationThickness);
                point3D_L1 = new GePoint3d(point3D_L1.x, point3D_L1.y + edge, point3D_L1.z);
                //左下
                GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y + L, point3D_L1.z - depth);

                //（左视图）涵洞右侧 换填点位
                //右上
                GePoint3d point3D_R1 = new GePoint3d(startPoint.x, (startPoint.y - culvertWidth / 2) - edge * id - foundationWidth, startPoint.z - depth * id - foundationThickness);
                point3D_R1 = new GePoint3d(point3D_R1.x, point3D_R1.y - edge, point3D_R1.z);
                //右下
                GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y - L, point3D_R1.z - depth);

                //线 左下角逆时针转 左下 右下 右上 左上
                IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
                IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R2));
                IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_L2));
                IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_L1));

                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveArray.add(curve1);
                curveArray.add(curve2);
                curveArray.add(curve3);
                curveArray.add(curve4);

                //体
                //延x轴向量拉伸
                GeVec3d v3d = new GeVec3d(length, 0, Math.Tan(Math.PI / 180 * 90 * slope) * length);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);
                graphics.addSolid(solid);

                #region 加厚部分
                //(顶视图左上加厚点 左侧加厚=LJ
                GePoint3d point3D_LJ1 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z - thickenedDepth);
                //(顶视图左下加厚点 左侧加厚=LJ
                GePoint3d point3D_LJ2 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z - thickenedDepth);
                //(左视图)线
                IGeCurveBase curve5 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L2, point3D_R2));
                IGeCurveBase curve6 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R2, point3D_LJ2));
                IGeCurveBase curve7 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ2, point3D_LJ1));
                IGeCurveBase curve8 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ1, point3D_L2));
                //(左视图)面
                GeCurveArray curveList = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList.add(curve5);
                curveList.add(curve6);
                curveList.add(curve7);
                curveList.add(curve8);
                graphics.addCurveArray(curveList);
                //(左视图)体
                GeExtrusionInfo extrusion = new GeExtrusionInfo(curveList, new GeVec3d(length, 0, Math.Tan(Math.PI / 180 * 90 * slope) * length), true);
                IGeSolidBase geSolid = IGeSolidBase.createGeExtrusion(extrusion);
                graphics.addSolid(geSolid);
                #endregion
                graphics = cropThicken(graphics, id, depth, thickenedDepth, thickenedLength, length, angle_L, angle_R, bottomWidth, slope, foundationThickness);

                //材质
                //BPMaterial.setMaterialToEntity(graphics, material, true);

                return graphics;
            }
            else
            {
                MessageBox.Show("数据输入错误！！");
                return null;
            }
            #endregion
        }


        /// <summary>
        /// 分离式换填剪切最后一层 加厚
        /// </summary>
        /// <param name="graphics">目标集</param>
        /// <param name="angle_L">洞口角度</param>
        /// <param name="angle_R">洞口角度</param>
        /// <param name="width">最底部宽度一半</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <param name="foundationThickness">基础厚度</param>
        /// <returns>返回剪切后的左右视图加厚起始点</returns>
        public static BPGraphics cropThicken(BPGraphics graphics, double id, double depth, double edgeThickeningDepth, double edgeThickeningLength, double length, double angle_L, double angle_R, double width, double slope, double foundationThickness)
        {
            slope = Math.Tan(Math.PI / 180 * 90 * slope);
            GePoint3d ptL1 = new GePoint3d(0, width, -depth * id - depth - edgeThickeningDepth - foundationThickness);//顶视图左上
            GePoint3d ptL2 = new GePoint3d(0, -width, ptL1.z);//顶视图左下
            GePoint3d ptR1 = new GePoint3d(length, width, ptL1.z + length * slope);//顶视图右上
            GePoint3d ptR2 = new GePoint3d(length, -width, ptL1.z + length * slope);//顶视图右下
            if (angle_L != 0 && angle_R != 0)
            {
                //(左视图)
                //换填底部线
                IGeCurveBase geCurve_L1 = IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2));
                //换填底部宽度
                double wallLength = 10;
                geCurve_L1.getLength(ref wallLength);
                //换填角度斜边长度
                double hypotenuseLength = wallLength / Math.Cos(angle_L * Math.PI / 180);
                //换填角度短边长度
                double oppositeSide = Math.Abs(hypotenuseLength * Math.Sin(angle_L * Math.PI / 180));
                GePoint3d point_L = GePoint3d.createByZero();
                if (angle_L > 0)
                    //旋转角度后的点
                    point_L = Helper.Rotation(ptL2, ptL1, hypotenuseLength, -angle_L);
                else
                    //旋转角度后的点(左视图)
                    point_L = Helper.Rotation(ptL1, ptL2, hypotenuseLength, Math.Abs(angle_L));

                //斜边和短边
                IGeCurveBase geCurve_L2 = IGeCurveBase.createSegment(new GeSegment3d(ptL2, new GePoint3d(point_L.x, point_L.y, ptL1.z - 1 + oppositeSide * slope)));
                IGeCurveBase geCurve_L3 = IGeCurveBase.createSegment(new GeSegment3d(new GePoint3d(point_L.x, point_L.y, ptL1.z - 1 + oppositeSide * slope), ptL1));
                //(左视图)面
                GeCurveArray curveList_L = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList_L.add(geCurve_L1);
                curveList_L.add(geCurve_L2);
                curveList_L.add(geCurve_L3);
                //体
                //延x轴向量拉伸
                GeVec3d v3d_L = new GeVec3d(0, 0, length);
                GeExtrusionInfo extrusionInfo_L = new GeExtrusionInfo(curveList_L, v3d_L, true);
                IGeSolidBase solid_L = IGeSolidBase.createGeExtrusion(extrusionInfo_L);

                //(右视图)
                //换填底部线
                IGeCurveBase geCurve_R1 = IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptR2));
                //旋转角度后的点
                GePoint3d point_R = GePoint3d.createByZero();
                if (angle_R > 0)
                    point_R = Helper.Rotation(ptR1, ptR2, hypotenuseLength, -angle_R);
                else
                    point_R = Helper.Rotation(ptR2, ptR1, hypotenuseLength, Math.Abs(angle_R));
                //斜边和短边
                IGeCurveBase geCurve_R2 = IGeCurveBase.createSegment(new GeSegment3d(ptR2, new GePoint3d(point_R.x, point_R.y, ptL1.z + (length - oppositeSide) * slope)));
                IGeCurveBase geCurve_R3 = IGeCurveBase.createSegment(new GeSegment3d(new GePoint3d(point_R.x, point_R.y, ptL1.z + (length - oppositeSide) * slope), ptR1));
                //(右视图)面
                GeCurveArray curveList_R = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                curveList_R.add(geCurve_R1);
                curveList_R.add(geCurve_R2);
                curveList_R.add(geCurve_R3);
                //体
                //延x轴向量拉伸
                GeVec3d v3d_R = new GeVec3d(0, 0, length);
                GeExtrusionInfo extrusionInfo_R = new GeExtrusionInfo(curveList_R, v3d_R, true);
                IGeSolidBase solid_R = IGeSolidBase.createGeExtrusion(extrusionInfo_R);

                //前视图 加厚
                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                if (angle_L > 0 && angle_R > 0)
                {
                    //点 左上角开始逆时针转 左上 左下 右下 右上
                    //Z值 为起点到该点的长度×坡度
                    ptL1 = new GePoint3d(point_L.x + edgeThickeningLength, point_L.y, ptL1.z + (oppositeSide + edgeThickeningLength) * slope);
                    ptL2 = new GePoint3d(ptL2.x + edgeThickeningLength, ptL2.y, ptL2.z + edgeThickeningLength * slope);
                    ptR2 = new GePoint3d(point_R.x - edgeThickeningLength, point_R.y, ptL2.z + (length - oppositeSide - edgeThickeningLength) * slope);
                    ptR1 = new GePoint3d(ptR1.x - edgeThickeningLength, ptR1.y, ptL1.z + (length - edgeThickeningLength) * slope);


                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL2, ptR2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR2, ptR1)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptL1)));
                }
                else if (angle_L < 0 && angle_R < 0)
                {
                    //点 左上角开始逆时针转 左上 左下 右下 右上
                    //Z值 为起点到该点的长度×坡度
                    ptL1 = new GePoint3d(ptL1.x + edgeThickeningLength, ptL1.y, ptL1.z + edgeThickeningLength * slope);
                    ptL2 = new GePoint3d(point_L.x + edgeThickeningLength, point_L.y, ptL2.z + (oppositeSide + edgeThickeningLength) * slope);
                    ptR2 = new GePoint3d(ptR2.x - edgeThickeningLength, ptR2.y, ptL2.z + (length - edgeThickeningLength) * slope);
                    ptR1 = new GePoint3d(point_R.x - edgeThickeningLength, point_R.y, ptL1.z + (length - oppositeSide - edgeThickeningLength) * slope);

                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL2, ptR2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR2, ptR1)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptL1)));
                }
                else if (angle_L > 0 && angle_R < 0)
                {
                    //点 左上角开始逆时针转 左上 左下 右下 右上
                    //Z值 为起点到该点的长度×坡度
                    ptL1 = new GePoint3d(point_L.x + edgeThickeningLength, point_L.y, ptL1.z + (oppositeSide + edgeThickeningLength) * (slope));
                    ptL2 = new GePoint3d(ptL2.x + edgeThickeningLength, ptL2.y, ptL2.z + edgeThickeningLength * slope);
                    ptR2 = new GePoint3d(ptR2.x - edgeThickeningLength, ptR2.y, ptL2.z + (length - edgeThickeningLength) * (slope));
                    ptR1 = new GePoint3d(point_R.x - edgeThickeningLength, point_R.y, ptL1.z + (length - oppositeSide - edgeThickeningLength) * slope);

                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL2, ptR2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR2, ptR1)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptL1)));
                }
                else if (angle_L < 0 && angle_R > 0)
                {
                    //点 左上角开始逆时针转 左上 左下 右下 右上
                    //Z值 为起点到该点的长度×坡度
                    ptL1 = new GePoint3d(ptL1.x + edgeThickeningLength, ptL1.y, ptL1.z + edgeThickeningLength * (slope));
                    ptL2 = new GePoint3d(point_L.x + edgeThickeningLength, point_L.y, ptL2.z + (oppositeSide + edgeThickeningLength) * slope);
                    ptR2 = new GePoint3d(point_R.x - edgeThickeningLength, point_R.y, ptL2.z + (length - oppositeSide - edgeThickeningLength) * slope);
                    ptR1 = new GePoint3d(ptR1.x - edgeThickeningLength, ptR1.y, ptL1.z + (length - edgeThickeningLength) * slope);

                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL1, ptL2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptL2, ptR2)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR2, ptR1)));
                    curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(ptR1, ptL1)));
                }
                //graphics.addCurveVector(curveArray);
                //graphics.save();
                //体
                //延x轴向量拉伸
                GeVec3d v3d1 = new GeVec3d(0, 0, depth);
                GeVec3d v3d2 = new GeVec3d(0, 0, -depth);
                GeExtrusionInfo extrusionInfo1 = new GeExtrusionInfo(curveArray, v3d1, true);
                GeExtrusionInfo extrusionInfo2 = new GeExtrusionInfo(curveArray, v3d2, true);
                IGeSolidBase solid1 = IGeSolidBase.createGeExtrusion(extrusionInfo1);
                IGeSolidBase solid2 = IGeSolidBase.createGeExtrusion(extrusionInfo2);

                BPGraphics graphics1 = BPApplication.getInstance().getProjectManager().getActiveModel().createPhysicalGraphics();
                graphics1.addSolid(solid1);
                graphics1.addSolid(solid2);
                graphics1.addSolid(solid_L);
                graphics1.addSolid(solid_R);
                //graphics1.save();
                //差集
                BPGraphics graphics2 = Element_solid.BoolDifferenceSet(graphics, graphics1, false);
                //平移到原点
                GeTransform transform = GeTransform.create(-Math.Abs(wallLength / 2 * Math.Tan(angle_R * Math.PI / 180)), 0, 0);
                BPGraphicsUtils.transformPhysicalGraphics(graphics2, transform);

                return /*graphics1*/graphics2;
            }
            else
            {
                //前视图 加厚
                //面
                GeCurveArray curveArray = GeCurveArray.create(BoundaryType.BOUNDARY_TYPE_Outer);
                //点 左上角开始逆时针转
                //Z值 为起点到该点的长度×坡度
                GePoint3d point1 = new GePoint3d(ptL1.x + edgeThickeningLength, ptL1.y, ptL1.z + edgeThickeningLength * slope);
                GePoint3d point2 = new GePoint3d(ptL2.x + edgeThickeningLength, ptL2.y, ptL2.z + edgeThickeningLength * (slope));
                GePoint3d point3 = new GePoint3d(ptR2.x - edgeThickeningLength, ptR2.y, ptL2.z + (length - edgeThickeningLength) * (slope));
                GePoint3d point4 = new GePoint3d(ptR1.x - edgeThickeningLength, ptR1.y, ptL1.z + (length - edgeThickeningLength) * slope);

                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point1, point2)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point2, point3)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point3, point4)));
                curveArray.add(IGeCurveBase.createSegment(new GeSegment3d(point4, point1)));

                //体
                //延x轴向量拉伸
                GeVec3d v3d = new GeVec3d(0, 0, edgeThickeningDepth /*+ 1*/);
                GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
                IGeSolidBase solid = IGeSolidBase.createGeExtrusion(extrusionInfo);

                BPGraphics graphics1 = BPApplication.getInstance().getProjectManager().getActiveModel().createPhysicalGraphics();
                graphics1.addSolid(solid);
                //graphics1.save();
                //差集
                BPGraphics graphics2 = Element_solid.BoolDifferenceSet(graphics, graphics1, false);
                return graphics2;
            }
        }

        #region 分层创建
        /// <summary>
        /// 盖板涵换填
        /// </summary>
        /// <param name="point3Ds">左视图上一层底部两点（0为左，1为右）</param>
        /// <param name="culvertWidth">涵洞宽度</param>
        /// <param name="depth">换填深度</param>
        /// <param name="length">换填长度</param>
        /// <param name="gap">换填起点距左洞口距离</param>
        /// <param name="slopeRatio">换填坡比</param>
        /// <param name="lapelLength">换填襟边</param>
        /// <param name="thickenedLength">边部加厚长度</param>
        /// <param name="thickenedDepth">边部加厚深度</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <param name="angle">洞口角度</param>
        /// <param name="material">换填材质</param>
        /// <returns>返回新建层底部两点</returns>
        //public static void create(List<GePoint3d> point3Ds, double culvertWidth, double depth, double length, double gap, double slopeRatio, double lapelLength, double thickenedLength, double thickenedDepth, double slope, double angle, BPMaterial material)
        //{
        //    #region 循环创建三次
        //    //下一层图素集合
        //    List<BPGraphics> graphicsList = new List<BPGraphics>();
        //    //坐标原点
        //    GePoint3d Slope_subgrade = new GePoint3d(0, 0, 0);
        //    //L = 深度 * 坡比
        //    double L = depth * slopeRatio;
        //    //层数
        //    double count = 3;

        //    for (int i = 0; i < count; i++)
        //    {
        //        BPGraphics graphics = BPApplication.getInstance().getProjectManager().getActiveModel().createPhysicalGraphics();
        //        if (i == 0)
        //        {
        //            //（左视图）涵洞左侧 换填点位
        //            GePoint3d point3D_L1 = new GePoint3d(startPoint.x, startPoint.y + lapelLength, startPoint.z);
        //            GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y, point3D_L1.z - depth);
        //            GePoint3d point3D_L3 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z);

        //            //（左视图）涵洞右侧 换填点位
        //            GePoint3d point3D_R1 = new GePoint3d(startPoint.x, startPoint.y - culvertWidth - lapelLength, startPoint.z);
        //            GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y, point3D_R1.z - depth);
        //            GePoint3d point3D_R3 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z);

        //            //线
        //            IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
        //            IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R3));
        //            IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R3, point3D_L3));
        //            IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L3, point3D_L1));

        //            //面
        //            GeCurveArray curveArray = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //            curveArray.add(curve1);
        //            curveArray.add(curve2);
        //            curveArray.add(curve3);
        //            curveArray.add(curve4);

        //            //体
        //            GeVec3d v3d = new GeVec3d(length, 0, slope / 100 * length);
        //            GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
        //            IGeSolidBase solid = IGeSolidBase.createExtrusion(extrusionInfo);
        //            graphics.addSolid(solid);
        //            graphicsList.Add(graphics);

        //            //清除
        //            point3Ds.Clear();
        //            point3Ds.Add(point3D_L3);
        //            point3Ds.Add(point3D_R3);
        //            //return pointList;
        //        }
        //        else if (i != count - 1)
        //        {
        //            //（左视图）涵洞左侧 换填点位
        //            GePoint3d point3D_L1 = new GePoint3d(point3Ds[0].x, point3Ds[0].y + lapelLength, point3Ds[0].z);
        //            GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y, point3D_L1.z - depth);
        //            GePoint3d point3D_L3 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z);

        //            //（左视图）涵洞右侧 换填点位
        //            GePoint3d point3D_R1 = new GePoint3d(point3Ds[1].x, point3Ds[1].y - lapelLength, point3Ds[1].z);
        //            GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y, point3D_R1.z - depth);
        //            GePoint3d point3D_R3 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z);

        //            //线
        //            IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
        //            IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R3));
        //            IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R3, point3D_L3));
        //            IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L3, point3D_L1));

        //            //面
        //            GeCurveArray curveArray = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //            curveArray.add(curve1);
        //            curveArray.add(curve2);
        //            curveArray.add(curve3);
        //            curveArray.add(curve4);

        //            //体
        //            GeVec3d v3d = new GeVec3d(length, 0, slope / 100 * length);
        //            GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
        //            IGeSolidBase solid = IGeSolidBase.createExtrusion(extrusionInfo);
        //            graphics.addSolid(solid);
        //            graphicsList.Add(graphics);
        //            //清除
        //            point3Ds.Clear();
        //            point3Ds.Add(point3D_L3);
        //            point3Ds.Add(point3D_R3);
        //        }
        //        else
        //        {
        //            //（左视图）涵洞左侧 换填点位
        //            GePoint3d point3D_L1 = new GePoint3d(point3Ds[0].x, point3Ds[0].y + lapelLength, point3Ds[0].z);
        //            GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y, point3D_L1.z - depth);
        //            GePoint3d point3D_L3 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z);

        //            //（左视图）涵洞右侧 换填点位
        //            GePoint3d point3D_R1 = new GePoint3d(point3Ds[1].x, point3Ds[1].y - lapelLength, point3Ds[1].z);
        //            GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y, point3D_R1.z - depth);
        //            GePoint3d point3D_R3 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z);

        //            //线
        //            IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
        //            IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R3));
        //            IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R3, point3D_L3));
        //            IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L3, point3D_L1));

        //            //面
        //            GeCurveArray curveArray = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //            curveArray.add(curve1);
        //            curveArray.add(curve2);
        //            curveArray.add(curve3);
        //            curveArray.add(curve4);

        //            //体
        //            //延x轴向量拉伸
        //            GeVec3d v3d = new GeVec3d(length, 0, slope / 100 * length);
        //            GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
        //            IGeSolidBase solid = IGeSolidBase.createExtrusion(extrusionInfo);
        //            graphics.addSolid(solid);

        //            #region 加厚部分
        //            //(左视图)左 加厚=LJ
        //            GePoint3d point3D_LJ1 = new GePoint3d(point3D_L3.x, point3D_L3.y, point3D_L3.z - thickenedDepth);
        //            GePoint3d point3D_LJ2 = new GePoint3d(point3D_LJ1.x, point3D_LJ1.y + L, point3D_LJ1.z);
        //            //(左视图)右 加厚=RJ
        //            GePoint3d point3D_RJ1 = new GePoint3d(point3D_R3.x, point3D_R3.y, point3D_R3.z - thickenedDepth);
        //            GePoint3d point3D_RJ2 = new GePoint3d(point3D_RJ1.x, point3D_RJ1.y - L, point3D_RJ1.z);
        //            //(左视图)线
        //            IGeCurveBase curve5 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L3, point3D_R3));
        //            IGeCurveBase curve6 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R3, point3D_RJ2));
        //            IGeCurveBase curve7 = IGeCurveBase.createSegment(new GeSegment3d(point3D_RJ2, point3D_LJ2));
        //            IGeCurveBase curve8 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ2, point3D_L3));
        //            //(左视图)面
        //            GeCurveArray curveList = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //            curveList.add(curve5);
        //            curveList.add(curve6);
        //            curveList.add(curve7);
        //            curveList.add(curve8);
        //            graphics.addCurveVector(curveList);
        //            //(左视图)体
        //            GeExtrusionInfo extrusion = new GeExtrusionInfo(curveList, new GeVec3d(length, 0, slope / 100 * length), true);
        //            IGeSolidBase geSolid = IGeSolidBase.createExtrusion(extrusion);
        //            graphics.addSolid(geSolid);
        //            #endregion

        //            graphicsList.Add(graphics);


        //            //是否剪切
        //            if (i == count - 1)
        //            {
        //                for (int j = 0; j < graphicsList.Count(); j++)
        //                {
        //                    if (j != graphicsList.Count() - 1)
        //                    {
        //                        crop(graphicsList[j], point3D_LJ2, point3D_RJ2, new GePoint3d(point3D_LJ2.x + length, point3D_LJ2.y, point3D_LJ2.z), new GePoint3d(point3D_RJ2.x + length, point3D_RJ2.y, point3D_RJ2.z), angle, depth, length, slope, material);
        //                    }
        //                    else
        //                    {
        //                        cropThicken(graphicsList[j], point3D_LJ2, point3D_RJ2, new GePoint3d(point3D_LJ2.x + length, point3D_LJ2.y, point3D_LJ2.z), new GePoint3d(point3D_RJ2.x + length, point3D_RJ2.y, point3D_RJ2.z), angle, depth, length, slope, thickenedLength, material);
        //                    }
        //                }
        //                //清除
        //                point3Ds.Clear();
        //            }
        //            else
        //            {
        //                //清除
        //                point3Ds.Clear();
        //                point3Ds.Add(point3D_L3);
        //                point3Ds.Add(point3D_R3);
        //            }
        //        }
        //    }
        //    #endregion
        //}

        /// <summary>
        /// 盖板涵换填(起始层)
        /// </summary>
        /// <param name="culvertWidth">涵洞宽度</param>
        /// <param name="depth">换填深度</param>
        /// <param name="length">换填长度</param>
        /// <param name="gap">换填起点距左洞口距离</param>
        /// <param name="slopeRatio">换填坡比</param>
        /// <param name="lapelLength">换填襟边</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <param name="angle">洞口角度</param>
        /// <param name="material">换填材质</param>
        /// <returns>返回新建层底部两点</returns>
        //public static List<GePoint3d> createFirst(BPGraphics graphics, double culvertWidth, double depth, double length, double gap, double slopeRatio, double lapelLength, double slope, double angle, BPMaterial material)
        //{
        //    //坐标原点
        //    GePoint3d Slope_subgrade = new GePoint3d(0, 0, 0);
        //    //L = 深度 * 坡比
        //    double L = depth * slopeRatio;

        //    //（左视图）涵洞左侧 换填点位
        //    GePoint3d point3D_L1 = new GePoint3d(startPoint.x, startPoint.y + lapelLength, startPoint.z);
        //    GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y, point3D_L1.z - depth);
        //    GePoint3d point3D_L3 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z);

        //    //（左视图）涵洞右侧 换填点位
        //    GePoint3d point3D_R1 = new GePoint3d(startPoint.x, startPoint.y - culvertWidth - lapelLength, startPoint.z);
        //    GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y, point3D_R1.z - depth);
        //    GePoint3d point3D_R3 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z);

        //    //线
        //    IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
        //    IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R3));
        //    IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R3, point3D_L3));
        //    IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L3, point3D_L1));

        //    //面
        //    GeCurveArray curveArray = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //    curveArray.add(curve1);
        //    curveArray.add(curve2);
        //    curveArray.add(curve3);
        //    curveArray.add(curve4);

        //    //体
        //    GeVec3d v3d = new GeVec3d(length, 0, slope / 100 * length);
        //    GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
        //    IGeSolidBase solid = IGeSolidBase.createExtrusion(extrusionInfo);
        //    graphics.addSolid(solid);

        //    //剪切
        //    crop(graphics, point3D_L3, point3D_R3, new GePoint3d(point3D_L3.x + length, point3D_L3.y, point3D_L3.z), new GePoint3d(point3D_R3.x + length, point3D_R3.y, point3D_R3.z), angle, depth, length, slope, material);

        //    //BPMaterial.setMaterialToEntity(graphics1, material, true);
        //    //graphics1.save();
        //    List<GePoint3d> pointList = new List<GePoint3d>
        //    {
        //        point3D_L3,point3D_R3
        //    };
        //    return pointList;
        //}

        /// <summary>
        /// 盖板涵换填(中间层)
        /// </summary>
        /// <param name="point3Ds">左视图上一层底部两点（0为左，1为右）</param>
        /// <param name="depth">换填深度</param>
        /// <param name="length">换填长度</param>
        /// <param name="gap">换填起点距左洞口距离</param>
        /// <param name="slopeRatio">换填坡比</param>
        /// <param name="lapelLength">换填襟边</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <param name="angle">洞口角度</param>
        /// <param name="material">换填材质</param>
        /// <returns>返回新建层底部两点</returns>
        //public static List<GePoint3d> createMid(BPGraphics graphics, List<GePoint3d> point3Ds, double depth, double length, double gap, double slopeRatio, double lapelLength, double slope, double angle, BPMaterial material)
        //{
        //    //L = 深度 * 坡比
        //    double L = depth * slopeRatio;
        //    //（左视图）涵洞左侧 换填点位
        //    GePoint3d point3D_L1 = new GePoint3d(point3Ds[0].x, point3Ds[0].y + lapelLength, point3Ds[0].z);
        //    GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y, point3D_L1.z - depth);
        //    GePoint3d point3D_L3 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z);

        //    //（左视图）涵洞右侧 换填点位
        //    GePoint3d point3D_R1 = new GePoint3d(point3Ds[1].x, point3Ds[1].y - lapelLength, point3Ds[1].z);
        //    GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y, point3D_R1.z - depth);
        //    GePoint3d point3D_R3 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z);

        //    //线
        //    IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
        //    IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R3));
        //    IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R3, point3D_L3));
        //    IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L3, point3D_L1));

        //    //面
        //    GeCurveArray curveArray = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //    curveArray.add(curve1);
        //    curveArray.add(curve2);
        //    curveArray.add(curve3);
        //    curveArray.add(curve4);

        //    //体
        //    GeVec3d v3d = new GeVec3d(length, 0, slope / 100 * length);
        //    GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
        //    IGeSolidBase solid = IGeSolidBase.createExtrusion(extrusionInfo);
        //    graphics.addSolid(solid);

        //    //剪切
        //    crop(graphics, point3D_L3, point3D_R3, new GePoint3d(point3D_L3.x + length, point3D_L3.y, point3D_L3.z), new GePoint3d(point3D_R3.x + length, point3D_R3.y, point3D_R3.z), angle, depth, length, slope, material);
        //    ////材质
        //    //BPMaterial.setMaterialToEntity(graphics1, material, true);
        //    //graphics1.save();
        //    //清除
        //    point3Ds.Clear();
        //    point3Ds.Add(point3D_L3);
        //    point3Ds.Add(point3D_R3);
        //    return point3Ds;
        //}

        /// <summary>
        /// 盖板涵换填(最后一层)
        /// </summary>
        /// <param name="point3Ds">左视图上一层底部两点（0为左，1为右）</param>
        /// <param name="culvertWidth">涵洞宽度</param>
        /// <param name="depth">换填深度</param>
        /// <param name="length">换填长度</param>
        /// <param name="gap">换填起点距左洞口距离</param>
        /// <param name="slopeRatio">换填坡比</param>
        /// <param name="lapelLength">换填襟边</param>
        /// <param name="thickenedLength">边部加厚长度</param>
        /// <param name="thickenedDepth">边部加厚深度</param>
        /// <param name="slope">涵洞底部坡度(上为正，下为负)</param>
        /// <param name="angle">洞口角度</param>
        /// <param name="material">换填材质</param>
        /// <returns>返回新建层底部两点</returns>
        //public static List<GePoint3d> createFinal(BPGraphics graphics, List<GePoint3d> point3Ds, double culvertWidth, double depth, double length, double gap, double slopeRatio, double lapelLength, double thickenedLength, double thickenedDepth, double slope, double angle, BPMaterial material)
        //{
        //    //L = 深度 * 坡比
        //    double L = depth * slopeRatio;
        //    //（左视图）涵洞左侧 换填点位
        //    GePoint3d point3D_L1 = new GePoint3d(point3Ds[0].x, point3Ds[0].y + lapelLength, point3Ds[0].z);
        //    GePoint3d point3D_L2 = new GePoint3d(point3D_L1.x, point3D_L1.y, point3D_L1.z - depth);
        //    GePoint3d point3D_L3 = new GePoint3d(point3D_L2.x, point3D_L2.y + L, point3D_L2.z);

        //    //（左视图）涵洞右侧 换填点位
        //    GePoint3d point3D_R1 = new GePoint3d(point3Ds[1].x, point3Ds[1].y - lapelLength, point3Ds[1].z);
        //    GePoint3d point3D_R2 = new GePoint3d(point3D_R1.x, point3D_R1.y, point3D_R1.z - depth);
        //    GePoint3d point3D_R3 = new GePoint3d(point3D_R2.x, point3D_R2.y - L, point3D_R2.z);

        //    //线
        //    IGeCurveBase curve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L1, point3D_R1));
        //    IGeCurveBase curve2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R1, point3D_R3));
        //    IGeCurveBase curve3 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R3, point3D_L3));
        //    IGeCurveBase curve4 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L3, point3D_L1));

        //    //面
        //    GeCurveArray curveArray = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //    curveArray.add(curve1);
        //    curveArray.add(curve2);
        //    curveArray.add(curve3);
        //    curveArray.add(curve4);

        //    //graphics.addCurveVector(curveArray);
        //    //体
        //    //延x轴向量拉伸
        //    GeVec3d v3d = new GeVec3d(length, 0, slope / 100 * length);
        //    GeExtrusionInfo extrusionInfo = new GeExtrusionInfo(curveArray, v3d, true);
        //    IGeSolidBase solid = IGeSolidBase.createExtrusion(extrusionInfo);
        //    //graphics.addSolid(solid);
        //    //graphics.save();

        //    #region 加厚部分
        //    //(左视图)左 加厚=LJ
        //    GePoint3d point3D_LJ1 = new GePoint3d(point3D_L3.x, point3D_L3.y, point3D_L3.z - thickenedDepth);
        //    GePoint3d point3D_LJ2 = new GePoint3d(point3D_LJ1.x, point3D_LJ1.y + L, point3D_LJ1.z);
        //    //(左视图)右 加厚=RJ
        //    GePoint3d point3D_RJ1 = new GePoint3d(point3D_R3.x, point3D_R3.y, point3D_R3.z - thickenedDepth);
        //    GePoint3d point3D_RJ2 = new GePoint3d(point3D_RJ1.x, point3D_RJ1.y - L, point3D_RJ1.z);
        //    //(左视图)线
        //    IGeCurveBase curve5 = IGeCurveBase.createSegment(new GeSegment3d(point3D_L3, point3D_R3));
        //    IGeCurveBase curve6 = IGeCurveBase.createSegment(new GeSegment3d(point3D_R3, point3D_RJ2));
        //    IGeCurveBase curve7 = IGeCurveBase.createSegment(new GeSegment3d(point3D_RJ2, point3D_LJ2));
        //    IGeCurveBase curve8 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ2, point3D_L3));
        //    //(左视图)面
        //    GeCurveArray curveList = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //    curveList.add(curve5);
        //    curveList.add(curve6);
        //    curveList.add(curve7);
        //    curveList.add(curve8);
        //    //graphics.addCurveVector(curveList);
        //    //(左视图)体
        //    GeExtrusionInfo extrusion = new GeExtrusionInfo(curveList, new GeVec3d(thickenedLength, 0, slope / 100 * thickenedLength), true);
        //    IGeSolidBase geSolid = IGeSolidBase.createExtrusion(extrusion);
        //    //graphics.addSolid(geSolid);


        //    //(右视图)右 加厚=RJ
        //    GePoint3d point3D_RJ3 = new GePoint3d(v3d.point3d().x, v3d.point3d().y + point3D_L3.y, v3d.point3d().z + point3D_L3.z);
        //    GePoint3d point3D_RJ4 = new GePoint3d(point3D_RJ3.x, point3D_RJ3.y, point3D_RJ3.z - thickenedDepth);
        //    GePoint3d point3D_RJ5 = new GePoint3d(point3D_RJ4.x, point3D_RJ4.y + L, point3D_RJ4.z);
        //    //(右视图)左 加厚=LJ
        //    GePoint3d point3D_LJ3 = new GePoint3d(v3d.point3d().x, v3d.point3d().y + point3D_R3.y, v3d.point3d().z + point3D_R3.z);
        //    GePoint3d point3D_LJ4 = new GePoint3d(point3D_LJ3.x, point3D_LJ3.y, point3D_LJ3.z - thickenedDepth);
        //    GePoint3d point3D_LJ5 = new GePoint3d(point3D_LJ4.x, point3D_LJ4.y - L, point3D_LJ4.z);
        //    //(右视图)线
        //    curve5 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ3, point3D_RJ3));
        //    curve6 = IGeCurveBase.createSegment(new GeSegment3d(point3D_RJ3, point3D_RJ5));
        //    curve7 = IGeCurveBase.createSegment(new GeSegment3d(point3D_RJ5, point3D_LJ5));
        //    curve8 = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ5, point3D_LJ3));
        //    //(右视图)面
        //    GeCurveArray curveList2 = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //    curveList2.add(curve5);
        //    curveList2.add(curve6);
        //    curveList2.add(curve7);
        //    curveList2.add(curve8);
        //    //graphics.addCurveVector(curveList);
        //    //(右视图)体
        //    GeExtrusionInfo extrusion2 = new GeExtrusionInfo(curveList2, new GeVec3d(-thickenedLength, 0, -slope / 100 * thickenedLength), true);
        //    IGeSolidBase geSolid2 = IGeSolidBase.createExtrusion(extrusion2);
        //    //graphics.addSolid(geSolid2);
        //    #endregion
        //    #region 洞口角度布尔
        //    //(左视图)
        //    //换填底部线
        //    IGeCurveBase curveBase = IGeCurveBase.createSegment(new GeSegment3d(point3D_LJ2, point3D_RJ2));
        //    //换填宽度
        //    double wallLength = curveBase.length;
        //    //换填角度偏移长度
        //    double LeftLateralOffset = (wallLength) * Math.Tan((90 - angle) * Math.PI / 180);
        //    //旋转角度后的点
        //    var point_L = Helper.Rotation(new GePoint3d(point3D_LJ2.x, point3D_LJ2.y, point3D_LJ2.z), new GePoint3d(point3D_RJ2.x, point3D_RJ2.y, point3D_RJ2.z), LeftLateralOffset, angle);
        //    //斜边和短边
        //    IGeCurveBase geCurve1 = IGeCurveBase.createSegment(new GeSegment3d(point3D_RJ2, new GePoint3d(point_L.x, point_L.y, point_L.z)));
        //    IGeCurveBase geCurve2 = IGeCurveBase.createSegment(new GeSegment3d(new GePoint3d(point_L.x, point_L.y, point_L.z), point3D_LJ2));
        //    //(左视图)面
        //    GeCurveArray curveList3 = GeCurveArray.create(GeCurveArray.BoundaryType.Outer);
        //    curveList3.add(curveBase);
        //    curveList3.add(geCurve1);
        //    curveList3.add(geCurve2);
        //    graphics.addCurveVector(curveList3);

        //    //(右视图)
        //    //换填底部线
        //    IGeCurveBase curveBase2 = IGeCurveBase.createSegment(new GeSegment3d(point3D_RJ5, point3D_LJ5));
        //    #endregion


        //    graphics.save();

        //    System.String strAppPath = BPApplication.singleton().getAppPath();

        //    System.String strPic1 = strAppPath + "Support\\QDPicture\\concrete.jpg";
        //    System.String strPic2 = strAppPath + "Support\\QDPicture\\jianzhuyujiegou.png";

        //    //按尺寸贴图
        //    material.name = "matTest2";
        //    material.mapFile = strPic1;
        //    material.isValid = true;
        //    BPMaterial.setMaterialToEntity(graphics, material, true);

        //    //按比例贴图
        //    //BPGraphics graphics2 = BPApplication.getInstance().getProjectManager().getActiveModel().createPhysicalGraphics();
        //    //solid.transform(GeTransform.create(new GePoint3d(4000, 0, 0)));
        //    //graphics2.addSolid(solid);
        //    //graphics2.save();
        //    //BPMaterial material2 = new BPMaterial();
        //    //material2.name = "matTest2";
        //    //material2.mapFile = strPic2;
        //    //material2.isValid = true;
        //    //material2.mapUnit = BPMaterialMapUnit.mRelative;
        //    //BPMaterial.setMaterialToEntity(graphics2, material2, true);
        //    //BPMaterial.updateMaterial(material2, true, true, true, doc);
        //    graphics.save();
        //    //清除
        //    point3Ds.Clear();
        //    point3Ds.Add(point3D_LJ5);
        //    point3Ds.Add(point3D_RJ5);
        //    return point3Ds;
        //}

        #endregion

    }
}
